const storage = {
  storage: localStorage,
  setStorageType: function (type: 'localStorage' | 'sessionStorage' = 'localStorage') {
    this.storage = window[type];
  },
  get: function (key: string) {
    return this.storage.getItem(key);
  },
  set: function (key: string, value: any) {
    this.storage.setItem(key, value);
  },
  remove: function (key: string) {
    this.storage.removeItem(key);
  },
  clear: function () {
    this.storage.clear();
  },
  getStorage: function () {
    return this.storage;
  }
}

Object.defineProperty(storage, 'storage', {
  enumerable: false,
  configurable: false
})

export default storage